#include <gtk/gtk.h>
#include "common.h"

GdkPixbuf *create_pixbuf(const gchar *filename)
{
	GdkPixbuf *pixbuf;
	GError *err = NULL;

	/*
	 * gdk_pixbuf_new_from_file从一个文件中加载图像数据
	 * 从而生成一个新的pixbuf。图像格式由系统自动检测。
	 */
	pixbuf = gdk_pixbuf_new_from_file(filename, &err);

	if(NULL == pixbuf) {
		fprintf(stderr, "%s\n", err->message);
		g_error_free(err);
	}
	return pixbuf;
}

int main(int argc,char *argv[])
{
    GtkWidget *window;
    GdkColor color_black_ = {0x0, 0x0, 0x0, 0x0};
    
    gtk_init(&argc,&argv);
    
    /* create the main, top level, window */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    
    /* give it the title */
    gtk_window_set_title(GTK_WINDOW(window), TITLE);
    
    gtk_window_set_default_size(GTK_WINDOW(window), 230, 150);	/*设置窗口大小*/
    gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &color_black_); /*设置为黑色背景*/

    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf("test.png"));


    /* connect the destroy signal of the window to gtk_main_quit
     * when the window is about to be destroyed we get a notification and
     * stop the main GTK+ loop
     */
    g_signal_connect(window,"destroy",G_CALLBACK(gtk_main_quit),NULL);
    
    /* make sure that everything, window and label, are visible */
    gtk_widget_show_all(window);
    
    /* start the main loop, and let it rest until the application is closed */
    gtk_main();
    
    return 0;
} 
